package work812;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class work1 {
  public static void main(String[] args) {
    FileOutputStream fos = null;
    FileInputStream fis = null;
    try {
      File file = new File("E:\\bdqn\\javaDemo\\test.txt");
      byte[] bytes = new byte[1024];
      if (file.exists()){
        System.out.println("文件已存在");
      }
      fos = new FileOutputStream(file,true);
      fos.write("hello".getBytes());
      fis = new FileInputStream(file);
      int i;
      while ((i = fis.read(bytes))!= -1){
        String content = new String(bytes,0,bytes.length);
        System.out.println(content);

      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        fis.close();
        fos.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

  }
}
